package org.example.business.endpoint.http.event.message;

import lombok.extern.slf4j.Slf4j;
import org.example.objevent.event.Event;
import org.example.objevent.event.EventActor;
import org.example.objevent.event.EventBus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class HttpReqActor implements EventActor<HttpMsg> {

    @Autowired
    private EventBus bus;

    @Override
    public String getWatchEvent() {
        return "HTTP_REQ";

    }

    @Override
    public void act(HttpMsg httpMsg) {
        log.info("处理请求消息 [msgId: {}, socketId: {}]", httpMsg.getMsgId(), httpMsg.getSocketId());

        httpMsg.getHttpRsp().setStatus(200);

        bus.publish(new Event("HTTP_RSP", httpMsg));

    }

}
